Ext.define('Admin.view.gooutApprove.GooutApproveGrid', {
    extend: Ext.grid.Panel,
    xtype: 'gooutApproveGrid',
    title: '\x3cb\x3e外出审批\x3c/b\x3e',
    id: 'gooutApproveGrid',
    bind: '{gooutApproveLists}',
    selModel: Ext.create('Ext.selection.CheckboxModel'),
    listeners: {
        itemdblclick: function (me, record, item, index, e, eOpts) {
            var selModel = this.getSelectionModel();
            if (selModel.hasSelection()) {
                var record = selModel.getSelection()[0];
                var gooutWindow = Ext.widget('gooutSAWindow', {
                    title: '查看外出申请信息',
                    items: {
                        xtype: 'gooutReadForm'
                    }
                });
                gooutWindow.disabled = true;
                gooutWindow.down('form').getForm().loadRecord(record);
            }
        }
    },
    columns: [{
        text: '员工工号',
        sortable: true,
        dataIndex: 'number',
        width: 120
    },

    {
        text: '姓名',
        sortable: true,
        dataIndex: 'name',
        width: 120
    }, {
        text: '外出日期',
        sortable: true,
        dataIndex: 'goOutDate',
        width: 100,
        renderer: Ext.util.Format.dateRenderer('Y/m/d')
    }, {
        text: '外出时间',
        sortable: true,
        dataIndex: 'goOutTime',
        width: 100
    }, {
        text: '外出原因',
        sortable: true,
        dataIndex: 'reason',
        width: 125
    }, {
        text: '是否用车',
        sortable: true,
        dataIndex: 'car',
        width: 125
    }, {
        text: '职位',
        sortable: true,
        dataIndex: 'job',
        width: 125
    }, {
        text: '部门',
        sortable: true,
        dataIndex: 'dept',
        width: 125
    }, {
        text: '申请状态',
        sortable: true,
        dataIndex: 'applyState',
        width: 125
    }, {
        xtype: 'actioncolumn',
        items: [{
            xtype: 'button',
            iconCls: 'x-fa fa-pencil',
            getClass: function (v, meta, rec) {
                if (rec.get('assignee') != '') {
                    return 'x-hidden';
                }
                return 'x-fa fa-pencil';
            },
            handler: 'onClickGooutApproveClaimButton',
            tooltip: '签收任务'
        }, {
            xtype: 'button',
            iconCls: 'x-fa fa-star',
            getClass: function (v, meta, rec) {
                if (rec.get('assignee') == '') {
                    return 'x-hidden';
                }
                return 'x-fa fa-star';
            },

            handler: 'onClickGooutApproveCompleteWindowButton',
            tooltip: '审核申请'

        }, {
            xtype: 'button',
            iconCls: 'x-fa fa-arrow-up',
            getClass: function (v, meta, rec) {
                if (rec.get('assignee') != rec.get('name')) {
                    return 'x-hidden';
                } else {
                    if (rec.get('applyState') == '审批中') {
                        return 'x-hidden';
                    }
                }
                return 'x-fa fa-arrow-up';
            },
            handler: 'gooutApplyUpload',
            tooltip: '重新申请'
        }, {
            xtype: 'button',
            iconCls: 'x-fa fa-close',
            getClass: function (v, meta, rec) {
                if (rec.get('assignee') != rec.get('name')) {
                    return 'x-hidden';
                } else {
                    if (rec.get('applyState') == '审批中') {
                        return 'x-hidden';
                    }
                }
                return 'x-fa fa-close';
            },
            handler: 'gooutApplyCancle',
            tooltip: '取消申请'
        }],
        cls: 'content-column',
        width: 120,
        dataIndex: 'bool',
        text: '操作',

    }],
    bbar: Ext.create('Ext.PagingToolbar', {
        bind: '{gooutLists}',
        displayInfo: true,
        displayMsg: '显示第 {0} - {1} 条数据 总计 {2}',
        emptyMsg: "没有任何数据"
    })
});
